$(document).ready(function() {
	var height1 = $(window).height() - 55;
	$("#main_layout").attr("style", "margin-top: 5px;width:100%;height:" + height1 + "px");
	$("#main_layout").layout("resize", {
		width : "100%",
		height : height1 + "px"
	});
});

$(window).resize(function() {
	var height1 = $(window).height() - 55;
	$("#main_layout").attr("style", "margin-top: 5px;width:100%;height:" + height1 + "px");
	$("#main_layout").layout("resize", {
		width : "100%",
		height : height1 + "px"
	});
});

/**
 * 条件质量控制搜索
 */
function searchReport(){
	//s_reportNumber,  s_sampleName, s_danwei, s_shangchuan, s_start, s_end
	$("#report").datagrid("load",{
		"s_reportNumber":$("#search_reportNumber").textbox("getValue"),
		"s_sampleName":$("#search_sampleName").textbox("getValue"),
		"s_danwei":$("#search_danwei").textbox("getValue"),
		"s_shangchuan":$("#search_shangchuan").textbox("getValue"),
		"s_start":$("#search_start").datebox("getValue"),
		"s_end":$("#search_end").datebox("getValue"),
	});
}

/**格式化使用状态列，显示机构详情*/
function showDanweiFormatter(value, rec, index){
	var danwei= (rec.danweiId != null &&rec.danweiId != "")?"<a style='cursor:pointer;color: #2A2AFF;'  " +
					"  onclick=\"openDialog('"+ rec.danweiId +"')\">"+rec.danweiCompName+"</a>":"";
	 return danwei;
}

/**格式化使用状态列，显示机构详情*/
function showShangchuanFormatter(value, rec, index){
	var shangchuan= (rec.shangchuanId != null &&rec.shangchuanId != "")?"<a style='cursor:pointer;color: #2A2AFF;'  " +
					"  onclick=\"openDialog('"+ rec.shangchuanId +"')\">"+rec.shangchuanCompName+"</a>":"";
	 return shangchuan;
}

/**格式化使用状态列，将传入值变成<a>标签*/
function pdfFileFormatter(value, rec, index){
	var pdf = (rec.filePath != null && rec.filePath != "")?"<a style='cursor:pointer;color: #2A2AFF;'  target=_blank  href='"+ rec.filePath.substr(1)+"')>[查看报告]</a>":"";
	 return pdf;
}

/**格式化使用状态列，时间只显示年月日模式*/
function dateHHmmssFormatter(value, rec, index){
	 return value != null?value.replace("T"," "):"";
}

//-----------------------上传者详情Start----------------------------------------------
function openDialog(uploaderId){
	$('#uploader_dialog').dialog({
        title: '机构名称',
    });
	$('#uploader_dialog').dialog('open');
	$.post("admin/iAndI/iAndI_iAndIModifyInfo.action?il.accountId=" + uploaderId,
	        function(data) {
			$('#accountId').text(data.il.accountId != null?data.il.accountId:"");
			$('#compName').text(data.il.compName != null?data.il.compName:"");
			$('#linkMan').text(data.il.linkMan != null?data.il.linkMan:"");
			$('#phone').text(data.il.phone != null?data.il.phone:"");
			$('#fax').text(data.il.fax != null?data.il.fax:"");
			$('#email').text(data.il.email != null?data.il.email:"");
    });
}

function dialog_close (){
	$('#uploader_dialog').dialog('close');
}

//-----------------------上传者详情End----------------------------------------------

/**
 * 删除资讯详情
 */
function remove(){
	
	var item="";
	try{
		item=$('#report').datagrid('getSelected');
		}catch (e) {
		}
		
	if(item==""||item==null){
		$.messager.alert('错误', '请选择要删除的详情项！', 'error');
		return;
	}
	
	$.messager.confirm("操作提示", "您确定要执行删除操作吗？", function (data) {  
		if (data) {
	$.ajax({
		data:{
			"report.reportId":item.reportId
		},
		url:"admin/report/report_removeReport.action",
		type:'POST',
		success:function(data){
			 var json = data;
	            if (json.result == "Success") {
	                $.messager.alert('提示', json.message, 'info');
	                $("#report").datagrid("load");
	            } else {
	                $.messager.alert('错误', json.message, 'error');
	            }
		}
	});
}
	});
}
